/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Daniel Cruz
 */
@Entity
@Table(name = "b_menu")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BMenu.findAll", query = "SELECT b FROM BMenu b"),
    @NamedQuery(name = "BMenu.findByMenId", query = "SELECT b FROM BMenu b WHERE b.menId = :menId"),
    @NamedQuery(name = "BMenu.findByMenNombre", query = "SELECT b FROM BMenu b WHERE b.menNombre = :menNombre"),
    @NamedQuery(name = "BMenu.findByMenNivel", query = "SELECT b FROM BMenu b WHERE b.menNivel = :menNivel"),
    @NamedQuery(name = "BMenu.findByMenUrl", query = "SELECT b FROM BMenu b WHERE b.menUrl = :menUrl"),
    @NamedQuery(name = "BMenu.findByMenEstado", query = "SELECT b FROM BMenu b WHERE b.menEstado = :menEstado")})
public class BMenu implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "men_id")
    private Long menId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 250)
    @Column(name = "men_nombre")
    private String menNombre;
    @Basic(optional = false)
    @NotNull
    @Column(name = "men_nivel")
    private int menNivel;
    @Size(max = 500)
    @Column(name = "men_url")
    private String menUrl;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "men_estado")
    private String menEstado;
    @OneToMany(mappedBy = "menPadre")
    private Collection<BMenu> bMenuCollection;
    @JoinColumn(name = "men_padre", referencedColumnName = "men_id")
    @ManyToOne
    private BMenu menPadre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bMenu")
    private Collection<BPermisoMenu> bPermisoMenuCollection;

    public BMenu() {
    }

    public BMenu(Long menId) {
        this.menId = menId;
    }

    public BMenu(Long menId, String menNombre, int menNivel, String menEstado) {
        this.menId = menId;
        this.menNombre = menNombre;
        this.menNivel = menNivel;
        this.menEstado = menEstado;
    }

    public Long getMenId() {
        return menId;
    }

    public void setMenId(Long menId) {
        this.menId = menId;
    }

    public String getMenNombre() {
        return menNombre;
    }

    public void setMenNombre(String menNombre) {
        this.menNombre = menNombre;
    }

    public int getMenNivel() {
        return menNivel;
    }

    public void setMenNivel(int menNivel) {
        this.menNivel = menNivel;
    }

    public String getMenUrl() {
        return menUrl;
    }

    public void setMenUrl(String menUrl) {
        this.menUrl = menUrl;
    }

    public String getMenEstado() {
        return menEstado;
    }

    public void setMenEstado(String menEstado) {
        this.menEstado = menEstado;
    }

    @XmlTransient
    public Collection<BMenu> getBMenuCollection() {
        return bMenuCollection;
    }

    public void setBMenuCollection(Collection<BMenu> bMenuCollection) {
        this.bMenuCollection = bMenuCollection;
    }

    public BMenu getMenPadre() {
        return menPadre;
    }

    public void setMenPadre(BMenu menPadre) {
        this.menPadre = menPadre;
    }

    @XmlTransient
    public Collection<BPermisoMenu> getBPermisoMenuCollection() {
        return bPermisoMenuCollection;
    }

    public void setBPermisoMenuCollection(Collection<BPermisoMenu> bPermisoMenuCollection) {
        this.bPermisoMenuCollection = bPermisoMenuCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (menId != null ? menId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BMenu)) {
            return false;
        }
        BMenu other = (BMenu) object;
        if ((this.menId == null && other.menId != null) || (this.menId != null && !this.menId.equals(other.menId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.BMenu[ menId=" + menId + " ]";
    }
    
}
